<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      let arr = [
        { name: "iPhone", price: 3888 },
        { name: "switch", price: 1688 },
        { name: "iPad", price: 2460 },
        { name: "mac", price: 18880 },
        { name: "ipod", price: 188 },
      ];

      let sum = 0;
      for( let i =0 ; i< arr.length;i++){
          sum += arr[i].price
      }

      console.log(`一共${sum}元`);
    </script>
  </body>
</html>
